import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
import {
  Column,
  Entity,
  ManyToMany,
  Relation,
  Tree,
  TreeChildren,
  TreeParent,
} from 'typeorm';

import { CompleteEntity } from '~/common/entity/common.entity';

import { UserEntity } from '../../user/user.entity';

@Entity({ name: 'sys_post' })
export class PostEntity extends CompleteEntity {
  @Column({ type: 'varchar' })
  @ApiProperty({ description: '岗位名称' })
  name: string;

  @Column({ type: 'varchar' })
  @ApiProperty({ description: '岗位编码' })
  code: string;

  @Column({ nullable: true, default: 0 })
  @ApiProperty({ description: '排序' })
  orderNo: number;

  @ApiHideProperty()
  @ManyToMany(() => UserEntity, user => user.posts)
  users: Relation<UserEntity[]>;
}
